<script type="text/javascript">
    function tambahPeriode() {
        loadPage(gs_path + '/hrd_periode');
    }

    $(document).ready(function() {
        // Setup Form
        $('#form_master').setupForm([
            { name: 'id_jadwal_pk', type: 'text', size: 'medium', maxlength: 10, noempty:true },
            { name: 'id_periode_fk', size: 'medium', data:<?php echo json_encode(array_merge(array(array('value'=>'','display'=>'')),$listPeriode)); ?> },
            { name: 'id_grub_absen_fk', size: 'medium', data:<?php echo json_encode(array_merge(array(array('value'=>'','display'=>'')),$listGrubAbsen)); ?> },
            { name: 'ket_jadwal', type: 'text', size:'medium' }
        ], 
            <?php echo json_encode($data); ?>
        );

        
        <?php if($mode=="edit"){ ?>
        $('#id_jadwal_pk').readonly();
        $('#id_periode_fk').readonly();
        $('#id_grub_absen_fk').readonly();
        <?php } ?>

        // Set Action Button
        var buttons = [{ label: 'Save', icon: 'save', onclick: function() { 
                            simpan_detail_jadwal();
                            $('#form_master').submitForm(   '/'+controller+'/ajax_post', 
                                {   
                                    onComplete : function(data){ eval('oData = '+data); loadPage('/'+controller+'/edit/?id_jadwal_pk='+(oData.genid!='' ? oData.genid : $('#id_jadwal_pk').getval())); }
                                } 
                            ); 
                        }},
                       { label: 'Close', icon: 'cancel', onclick: function() { loadPage('/'+controller+'/Index'); } }];
        setAction(buttons);
        
        // Create Tab
        $('#tt').tabs({ border:false });  
        
        // Focus at First Object
        $('#form_master').focusFirst();

    });
</script>

<div id="form_master_message" style="display:none;"></div>

<fieldset style="width:600px;">
<legend><b>Jadwal</b></legend>
<table class="tb_form" style="display:none; width:100%; " cellpadding="0" cellspacing="0" border="0">   
    <tr>
        <td class="label">Id Jadwal</td>
        <td><input id="id_jadwal_pk" /></td>
    </tr>
    <tr>
        <td class="label">Periode</td>
        <td><input id="id_periode_fk" /> <button class="easyui-linkbutton" iconCls="icon-add" onclick="tambahPeriode()">Tambah Periode</button></td>
    </tr>
    <tr>
        <td class="label">Grub Absen</td>
        <td><input id="id_grub_absen_fk" /></td>
    </tr>
    <tr>
        <td class="label">Keterangan</td>
        <td><input id="ket_jadwal" /></td>
    </tr>
</table>
</fieldset>
<br><br>

<div id="tt" class="easyui-tabs" style="min-height:400px;"> 

    <div title="Detail Jadwal" style="overflow:auto;padding:10px;">  
        <?php require_once('detail_jadwal.php'); ?>
    </div>

</div>